package cn.example.util.toolkit;

import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;

/**
 * Created by WuYB on 2017/4/27.
 */
public class NullUtil {

    private static class SingletonHolder {
        private static final NullUtil INSTANCE = new NullUtil();
    }

    private NullUtil() {
    }

    public static NullUtil getInstance() {
        return SingletonHolder.INSTANCE;
    }

    public boolean isNull(Map<?, ?> map) {
        return map == null || map.isEmpty();
    }

    public boolean isNull(String str) {
        return str == null || str.trim().isEmpty() || str.trim().equalsIgnoreCase("null");
    }

    public boolean isNull(List<?> list) {
        return list == null || list.isEmpty();
    }

    public boolean isNullObj(Object obj) {
        return obj == null || isNull(obj.toString());
    }

    public boolean isNull(Object[] objs) {
        if (objs != null && objs.length > 0) {
            for (Object obj : objs) {
                if (!isNullObj(obj)) {
                    return false;
                }
            }
            return true;
        } else {
            return true;
        }
    }

    public boolean isNull(Set<?> set) {
        return set == null || set.isEmpty();
    }

}
